#include "CBackGround.h"
LPDIRECT3DTEXTURE9 CBackGround::_datLien;
LPDIRECT3DTEXTURE9 CBackGround:: _bienDao;
void CBackGround::InitResoure()
{
	//Load anh nen
	_datLien=CSprites::LoadTexture(DATLIEN,0);
	_bienDao=CSprites::LoadTexture(BIENDAO,0);

}
CBackGround::CBackGround(void)
{
}
CBackGround::CBackGround(int left,int top,int kind)
{
	_typeObj	=-1;
	_layer		=0;

	_pRect->left=left;
	_pRect->top	=top;
	_kind		=kind;
	_isActive	=true;
	_id			=countObj++;
	_status		=0;
	infoDaw.index=0;
	infoDaw.lastTime=GetTickCount();
	switch (_kind)
	{
		//Khai bao cac thong so doi tuong theo kieu
	case 0:break;
	case 1:break;
	case 2:break;
	}
}
void CBackGround::Update(int leftRect,int Style)
{
	RECT rec;
	if(infoDaw.timeDelay!=0 && GetTickCount()-infoDaw.lastTime>infoDaw.timeDelay)
	{
		infoDaw.lastTime=GetTickCount();
		infoDaw.index=(infoDaw.index+1)%infoDaw.spriteCount;
	}
	rec.left=infoDaw.deltaXSprite+(infoDaw.index*infoDaw.width);
	rec.top=infoDaw.deltaXSprite;
	rec.bottom=rec.top+infoDaw.height;
	rec.right=rec.left+infoDaw.width;
	CSprites::_spriteHandler->Begin(D3DXSPRITE_ALPHABLEND);
	D3DXVECTOR3 position((float)(_pRect->left-leftRect),(float)_pRect->top,0);
	LPDIRECT3DTEXTURE9 _image;
	//Chon anh nen
	if (infoDaw.mapImage==1)
	{
		_image=_datLien;
	}
	else
	{
		_image=_bienDao;
	}
	CSprites::_spriteHandler->Begin(D3DXSPRITE_ALPHABLEND);
	CSprites::_spriteHandler->Draw(_image,
		&rec,
		NULL,
		&position,
		D3DCOLOR_XRGB(255,255,255));
	CSprites::_spriteHandler->End();
}
int CBackGround::Move()
{
	return 0;
}
void CBackGround::Collision(Object *Ob)
{
}
CBackGround::~CBackGround(void)
{
}






















